package com.datang.pet.service.impl;
/*
 * @auther 顶风少年
 * @mail dfsn19970313@foxmail.com
 * @date 2019-07-11 22:23
 * @notify
 * @version 1.0
 */

import com.datang.pet.mapper.SpecMapper;
import com.datang.pet.mapperExtend.GoodsMapperExtend;
import com.datang.pet.pojo.Spec;
import com.datang.pet.pojo.SpecExample;
import com.datang.pet.service.GoodsService;
import com.datang.pet.vo.GetGoodsInfo;
import com.datang.pet.vo.GoodsList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class GoodsServiceImpl implements GoodsService {
    @Autowired
    private GoodsMapperExtend goodsMapperExtend;
    @Autowired
    private SpecMapper specMapper;

    /*
     * @author 顶风少年
     * @date 2019/7/14 9:51
     * @mail dfsn199703132038@foxmail.com
     * @throws
     * @param
     * @result java.util.List<com.datang.pet.vo.GoodsList>
     * @notify 获取商品列表
     * version 1.0
     */
    public List<GoodsList> getGoodsList()throws Exception{
        try {
            return goodsMapperExtend.getGoodsList();
        }catch (Exception e){
            throw new Exception("获取商品列表失败");
        }
    }

    /*
     * @author 顶风少年
     * @date 2019/7/14 9:51
     * @mail dfsn199703132038@foxmail.com
     * @throws
     * @param
     * @param goodsId
     * @result com.datang.pet.vo.GetGoodsInfo
     * @notify 获取商品详情
     * version 1.0
     */
    public GetGoodsInfo getGoodsInfo(String goodsId)throws Exception{
        GetGoodsInfo goodsInfo = null;
//        try {
//
//        }catch (Exception e){
//            throw new Exception("获取商品详情失败");
//        }
        goodsInfo = goodsMapperExtend.getGoodsInfo(goodsId);
//        SpecExample specExample = new SpecExample();
//        SpecExample.Criteria criteria = specExample.createCriteria();
//        criteria.andGoodsIdEqualTo(goodsInfo.getId());
//        try {
//            List<Spec> specs = specMapper.selectByExample(specExample);
//            goodsInfo.setSpecList(specs);
//        }catch (Exception e){
//            throw new Exception("获取商品规格失败");
//        }
        return goodsInfo;
    }
}
